$(function(){
	function Formyz(){
		this.userName = $('#userName');
		this.init();
	}
	Formyz.prototype.init=function(){
		this.loginAction();
	}
	Formyz.prototype.loginAction = function(){
		var stop = true;
		this.userName.on('input',function(){
			var username=$(this).val();
			$.ajax({
				type:'post',
				url:'http://www.smilening.online/qqmusic/php/register.php',
				data:{
					name:username
				},
				success:function(data){
					if(!data){
						console.log('用户名正确');
						stop = true;
					}else{
						console.log('用户名错误');
						stop = false;
					}
				}
			});
			$('form').on('submit',function(){
				if(!stop){
					return false;//阻止按钮跳转。
				}
			});
		});
	}
	Formyz.prototype.regiterAction = function(){
			
	}

	new Formyz();
});

